package Threading;

public class Demo6 {

    //通过  lambda表达式  创建线程
    public static void Lambda1(){
        Thread thread=new Thread(()->{
            while(true){
                System.out.println("==============Thread1");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();

    }
    //通过  lambda表达式  创建线程
    public static void Lambda2(){
        Runnable runnable=()->{
            while(true){
                System.out.println("==============Thread2==============");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        Thread thread=new Thread(runnable);
        thread.start();

    }


    public static void main(String[] args) {
        //lambda表达式
        Lambda1();
        Lambda2();



    }
}
